Security and Authentication

Dynamically Set the Start Page Based on Logged-In User

Description
This customization demonstrates how to set the start page of an application based on the identity of the logged-in user.
Variables
Applies to
SignIn class
Code
 
/// 
/// Performs the custom redirect after successful login
/// 
protected override void RedirectOnSuccess()
{
			if (!string.IsNullOrEmpty(this.SuccessURL))
			{
				this.Page.Response.Redirect(this.SuccessURL);
			}
			else
			{
				string role = BaseClasses.Utils.SecurityControls.GetCurrentUserRoles();

				// GetCurrentUserRoles() will return semi-colon-delimited list of RoleIDsvalues such as {RoleID1;RoleID2}.
				//  Note, that for ActiveDirectory Security roles names are effectively roles IDs. Also note, that 
				// Active Directory and Azman roles can include domain name such as "MyDomain\RoleName"
				if (role == "") ((BaseApplicationPage)this.Page).RedirectBack(false);
				char [] separator = {';'};
				string[] roles = role.Split(separator, System.StringSplitOptions.RemoveEmptyEntries);
				bool includes = false;
				foreach(string r in roles)
				{
					if(r == "2")  includes =  true;
				}
				if (includes)
				{
					this.Page.Response.Redirect("../TableName/ShowTableNameTable.aspx");
				}
				else
				{
					((BaseApplicationPage)this.Page).RedirectBack(false);
				}
			}
}
     

Terms of Service Privacy Statement